package hr.ctg.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Serves images and other member content
 * 
 * @author Shane Bryzak
 */
public class LastUpdatesServlet extends HttpServlet {

	private static final long serialVersionUID = -8461940507241022247L;

	@Override
	public void init() {

	}

	@Override
	protected void doGet(final HttpServletRequest request,
			final HttpServletResponse response) throws ServletException,
			IOException {

		// response.setContentType("text/xml");
		// response.setCharacterEncoding("UTF-8");
		//
		// final PrintWriter out = response.getWriter();
		// final ObjektDAO objektDAO = (ObjektDAO) Component
		// .getInstance("objektDAO2");
		// final List<Objekt> lastUpdated = objektDAO.getLastUpdates();
		//
		// System.out.println("Dohvaceno " + lastUpdated.size() + "
		// objekata...");
		// System.out.println("Generiram xml dokument....");
		//
		// out.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
		// out.append("<root>");
		// for (final Objekt objekt : lastUpdated) {
		// out.append("<objekt>");
		// out.append("<tip>");
		// out.append(objekt.getTipObjekta().getNaziv());
		// out.append("</tip>");
		// out.append("<naziv>");
		// out.append(objekt.getNaziv());
		// out.append("</naziv>");
		// out.append("<link>");
		// out.append("/guides/objekti/objekt.seam?idObjekta="
		// + objekt.getIdObjekta());
		// out.append("</link>");
		// out.append("<mjesto>");
		// out.append(objekt.getMjesto().getNaziv());
		// out.append("</mjesto>");
		// out.append("</objekt>");
		// }
		// out.append("</root>");
		// out.flush();
		// out.close();
		// System.out.println("Zahtjev obradjen vracam se...");

	}

	// @SuppressWarnings("unchecked")
	// void copyRequestHeaders(final HttpServletRequest request, URL url)
	// throws IOException {
	// System.out.println("kopiram request headere...");
	// URLConnection urlConn = url.openConnection();
	// Enumeration<String> headers = request.getHeaderNames();
	// while (headers.hasMoreElements()) {
	// String header = headers.nextElement();
	// urlConn.setRequestProperty(header, request.getHeader(header));
	// System.out.println(header + "-" + request.getHeader(header));
	// }
	// }

	/*
	 * @SuppressWarnings("unchecked") void analyzeRequest(final
	 * HttpServletRequest request) {
	 * System.out.println(request.getAttributeNames());
	 * System.out.println(request.getCharacterEncoding());
	 * System.out.println(request.getContentType());
	 * System.out.println(request.getContextPath());
	 * System.out.println(request.getHeaderNames()); Enumeration<String>
	 * headers = request.getHeaderNames(); while (headers.hasMoreElements()) {
	 * String header = headers.nextElement(); System.out.println(header + "-" +
	 * request.getHeader(header)); } System.out.println(request.getLocale()); }
	 */
}
